import { reqGetSearchGoodsInfoData } from "@/api"
const state = {
  goodsInfo: {},
}
const actions = {
  // 获取搜索数据
  async getSearchGoodsInfoData({ commit }, searchParams) {
    const result = await reqGetSearchGoodsInfoData(searchParams)
    if (result.code === 200) {
      // console.log("获取搜索数据-->", result)
      commit("GOODS_INFO", result.data)
    } else {
      console.log("获取搜索数据失败", result.message)
    }
  },
}
const mutations = {
  // 保存搜索数据
  GOODS_INFO(state, payload) {
    // console.log("保存搜索数据--->", payload)
    state.goodsInfo = payload
  },
}
const getters = {
  // 属性列表
  attrsList(state) {
    return state.goodsInfo.attrsList
  },
  // 商品列表
  goodsList(state) {
    return state.goodsInfo.goodsList
  },
  // 商品品牌列表
  trademarkList(state) {
    return state.goodsInfo.trademarkList
  },
  //  商品总数量
  total(state) {
    return state.goodsInfo.total
  },
}

export default {
  namespaced: true, // 开启命名空间
  state,
  actions,
  mutations,
  getters,
}
